package com.accenture.agreco.beans.impl;

import com.accenture.agreco.beans.Classe;
import com.accenture.agreco.beans.Libro;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * User: a.greco
 * Date: 10/10/12
 * Time: 18.19
 */
public class StudenteImpl extends PersonaImpl {
    private int age;
    /*@Autowired*/ private Classe classe;
    private Libro[] libri;


    public StudenteImpl() {}
    public StudenteImpl(String nome, String cognome){
        super(nome, cognome);
    }
    public StudenteImpl(String nome, String cognome, int age){
        super(nome, cognome);
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Classe getClasse() {
        return classe;
    }

    public void setClasse(Classe classe) {
        this.classe = classe;
    }

    public Libro[] getLibri() {
        return libri;
    }

    public void setLibri(Libro[] libri) {
        this.libri = libri;
    }

    public String toString(){
        String libriStr = getLibriInAString();
        return "[Studente "+getNome()+" ::: Nome:"+getNome()+" ::: Cognome:"+getCognome()+" ::: Età:"+getAge()+" ::: Classe:"+(getClasse()==null?null:getClasse().getId())+" ::: Libri:"+libriStr+"]";
    }

    private String getLibriInAString() {
        String libriStr = "";
        if(libri != null && libri.length > 0){
            for(Libro l : libri){
                libriStr += "\""+l.getTitolo() +"\" (UCId:" + l.getUniqueCopyId()+") "+" - ";
            }
            libriStr = libriStr.substring(0, libriStr.length()-3);
        }
        return libriStr;
    }
}
